<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<title>Gwack Admin</title>
<link href="style.css" rel="stylesheet" type="text/css" />


</head>
<body>
<div id="container">
<?php include('menu.php');?>
<div id="content">
    <div id="leftBox">
        <div class="contentBox">
            <div class="contentBoxTop">
			<h3>Agent Load Unload Results</h3>
			</div><!-- end contentsBoxTop-->


<?php

$unload = "sudo /opt/gwack/unloadagent.sh";
$load = "sudo /opt/gwack/loadagent.sh";
$gwname = $_GET['name'];
$act = $_GET['act'];
$ipaddr = $_GET['ip'];
$type = $_GET['type'];
$path = $_GET['path'];
$remip = $_GET['remip'];
if ($type == "domain")
	$agent = "MTA";

elseif ($type == "po")
	$agent = "POA";
else
	echo "Agent type not known";


//echo "$gwname $act $ipaddr $type $path";

if ($act == "unload")
{
	$out = shell_exec("$unload $ipaddr $type $gwname $remip");

	if (isset($out)){

    echo '<div class="errorBox"><div class="errorBoxTop">&nbsp;</div>';
    echo '<div class="msgBoxContent errorIcon">';
    echo '<p>Error. Agent unload failed for reason '.$out.' </p>';
    echo '</div></div></div>';

    }

    else
    {

    echo '<div class="successBox">';
    echo '<div class="successBoxTop">&nbsp;</div>';
    echo '<div class="msgBoxContent successIcon">';
    echo '<p>Successfully unloaded GroupWise '.$agent.' for the '.$gwname.' '.$type.' ';
    echo '<br>and removed IP address '.$ipaddr.'</p> ';
    echo '</div></div></div>';
    }
}

elseif ($act == "load")

{
	$out = shell_exec("$load $path $ipaddr $type $gwname");
	if (isset($out)){

	echo '<div class="errorBox"><div class="errorBoxTop">&nbsp;</div>';
    echo '<div class="msgBoxContent errorIcon">';
    echo '<p>Error. Agent load  failed for reason '.$out.' </p>';
    echo '</div></div></div>';

	}

	else
	{

    echo '<div class="successBox">';
	echo '<div class="successBoxTop">&nbsp;</div>';
	echo '<div class="msgBoxContent successIcon">';
	echo '<p>Successfully loaded GroupWise '.$agent.' for the '.$gwname.' '.$type.' ';
	echo '<br>'.$agent.' is running against '.$path.' using IP address '.$ipaddr.'</p> ';
    echo '</div></div></div>';
	}

}

else
{
echo "action not defined";
}

?>

<a href="recovery.php?name=<?php echo $gwname;?>"><input type="image" alt="Back" src="images/back.jpg"></a>



		
		</div><!-- end contentsBox-->
	</div><!-- end leftBox-->
</div><!-- end content -->
</div><!-- end container -->
</body>
</html>
